/*******************************************************************************
 * Copyright (c) 2011 Grupo de Sistemas Inteligentes (GSI) - DIT UPM
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package es.upm.dit.gsi.eclipse.jadex.navigator;


/**
 * Class that represents the subnodes of a "Child" node of the agent file
 * @author pmunoz
 *
 */
public class SubChild { 
	private Child container; 
	private String header;
	private String description;
	private String nodeName;

	/**
	 * Constructor for the SubChild class
	 * 
	 * @param container node that contains the subnode
	 * @param header title to show in the tree view
	 * @param description description to show in the tree view
	 * @param nodeName kind of node
	 */
	public SubChild(Child container, String header, String description, String nodeName) {
		super();
		this.container = container;
		this.header = header;
		this.description = description;
		this.nodeName = nodeName;
	}
	
	
	/**
	 * 
	 * @return container node
	 */
	public Child getContainer() {
		return container;
	}

	/**
	 * 
	 * @return header
	 */
	public String getHeader() {
		return header;
	}

	/**
	 * 
	 * @return description
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * 
	 * @return node name
	 */
	public String getNodeName(){
		return nodeName;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		/*result = prime * result
				+ ((container == null) ? 0 : container.hashCode());*/
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((header == null) ? 0 : header.hashCode());
		result = prime * result
				+ ((nodeName == null) ? 0 : nodeName.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof SubChild))
			return false;
		SubChild other = (SubChild) obj;
		if (container == null) {
			if (other.container != null)
				return false;
		} else if (!container.equals(other.container))
			return false;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (header == null) {
			if (other.header != null)
				return false;
		} else if (!header.equals(other.header))
			return false;
		if (nodeName == null) {
			if (other.nodeName != null)
				return false;
		} else if (!nodeName.equals(other.nodeName))
			return false;
		return true;
	}


	@Override
	public String toString() {
		return getHeader() + " : " + getDescription(); //$NON-NLS-1$
	}


}
